package com.example.day03homework.DAO;

import com.example.day03homework.POJO.News;
import com.example.day03homework.POJO.Topic;

import java.util.List;

public class NewsDaolmpl extends BaseDao implements NewsDao {

    @Override
    public List<Topic> getAllTopic() {
        //对比使用框架的好处
        String sql = "SELECT * FROM topic";
        return select(Topic.class,sql);
    }

    @Override
    public List<News> getNewsByPageNo(int no, int size) {
        String sql = "SELECT * FROM news ORDER BY ncreateDate LIMIT ? , ? ";
        return select(News.class,sql,(no-1)*size,size);
    }

    @Override
    public int addNews(News news) {
        String sql = "INSERT INTO `news`(字段名) VALUES (?,?,?,?) ";

        return  updata(sql,news.getNauthor(),news.getNcontent());
    }
}


